package com.rj.bd.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.rj.bd.dao.UserMapper;
import com.rj.bd.entity.User;

@Service
@Transactional //事务
public class UserServiceImpl implements IUserService{
	
	
	@Autowired
	public UserMapper  userMapper;

	@Override
	public User login(String unumber, String upassword) {
		return userMapper.login(unumber, upassword);
	}

	@Override
	public List<User> queryAll() {
		return userMapper.queryAll();
	}

	@Override
	public List<Map> getPage(Map maps) {
		// TODO Auto-generated method stub
		 System.out.println("pageNo"+maps.get("pageNo")+"pageSize"+maps.get("pageSize"));
	     int pageNo=maps.get("pageNo")==null?1:Integer.valueOf(maps.get("pageNo")+"");
	     int pageSize=maps.get("pageSize")==null?2:Integer.valueOf(maps.get("pageSize")+"");

	     maps.put("start",(pageNo-1)*pageSize);
	     maps.put("end",pageSize);
	  return userMapper.getPage(maps);
	}

	@Override
	public List<User> queryByUid(String uid) {
		return userMapper.queryByUid(uid);
	}
	
	
	@Override
	public void add(User user) {
		// TODO Auto-generated method stub
		userMapper.add(user);
	}

	
}
